#!/usr/bin/env python

import pygtk
import gtk
import gobject
import webkit
import time
import re
import gettext

# for the 'save' thread
import thread

# from youtube-dl
import httplib
import socket
import time
import urllib2

_ = gettext.gettext

VERSION = "0.2.41"

class WebKitTest:
    
    def __init__(self):

        gobject.threads_init()
        
        video_id = 'http://www.youtube.com/v/wKaK31X7xAs'

        conversation = None

        view = webkit.WebView()
        view.open(video_id)

        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.add(view)
        scrolled_window.set_size_request(400,300)

        vbox = gtk.VBox(False, 0)

        dbutton = gtk.Button(None, gtk.STOCK_SAVE)
        dbutton.set_size_request(400,30)
        dbutton.connect('clicked', self.downloadVideo, video_id, conversation)

        vbox.pack_start(scrolled_window,True)

        vbox.pack_end(dbutton,False)

        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        #window.set_size_request(400,300)
        window.connect("destroy", gtk.main_quit)

        window.add(vbox)

        window.set_title('Emesene - YAYoutube')
        window.show_all()

    def downloadVideo(self, button, video, conversation):
        pass  


gtk.gdk.threads_init()
gtk.gdk.threads_enter()
test = WebKitTest()
gtk.main()
gtk.gdk.threads_leave()

